<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\models;

use Yii;
use yii\base\Model;
use app\models\Qa;
use app\models\Article;
use app\models\Tags;

class Sidebar extends Model {

    /**
     * 用户区块
     * @return type
     */
    public function User() {
        return $this->render('/sidebar/user');
    }

    /**
     * 获取热门问答
     * @return type
     */
    public function HotQa() {
        $qa_list = Qa::find()->where(['status' => '1',])->orderBy('id desc')->limit(5)->all();
        return $this->render('/sidebar/hot_qa', ['qa_list' => $qa_list]);
    }

    /**
     * 获取热门文章
     * @return type
     */
    public function HotArticle() {
        $article_list = Article::find()->where(['status' => '1',])->orderBy('id desc')->limit(5)->all();

        return $this->render('/sidebar/hot_article', ['article_list' => $article_list]);
    }

    /**
     * 获取热门标签
     */
    public function HotTags() {
        $tags = Tags::find()->orderBy('id desc')->limit(10)->all();

        return $this->render('/sidebar/hot_tags', ['tags' => $tags]);
    }

}
